package com.qianfeng.biz.impl;

import java.util.List;

import org.junit.Test;

import com.qianfeng.biz.IGoodsTypeBiz;
import com.qianfeng.dao.IGoodsTypeDao;
import com.qianfeng.dao.impl.GoodsTypeDaoImpl;
import com.qianfeng.dto.PageBean;
import com.qianfeng.entity.GoodType;

public class GoodsTypeBizImpl implements IGoodsTypeBiz {
	
	
	private IGoodsTypeDao gtDao = new GoodsTypeDaoImpl();

	@Override
	public List<GoodType> queryAllGoodsType() {
		return gtDao.queryAllGoodsType();
	}

	@Override
	public 	PageBean queryAllfenyeType(String currentPge,int pageSize) {
		
		PageBean page=new PageBean();
		 int count=gtDao.queryCount();
		 int i = Integer.parseInt(currentPge);
		 int rowIndex=(i-1)*pageSize;
		 double ct=count;
		 List<GoodType> gt=gtDao.queryfenyeList(rowIndex,pageSize);
		 Double tp=Math.ceil(ct/pageSize);
		 int totalPage=tp.intValue();
		 page.setTotalPage(totalPage);
		 page.setTotalCount(count);
		 page.setCurrPage(i);
		 page.setPageSize(pageSize);
		 page.setList(gt);
		return page;
	}

	@Override
	public GoodType getGoodTypeById(int typeid) {
		return gtDao.getGoodTypeById(typeid);
	}

	@Override
	public int deleteById(int typeid) {
		return gtDao.deleteById(typeid);
	}

	@Override
	public int updateGoodTypeInfo(GoodType goodType) {
		return gtDao.updateGoodTypeInfo(goodType);

	}

	

}
